package com.pn.mapper;

import com.github.pagehelper.Page;
import com.pn.entity.OutStore;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

@Mapper
public interface OutstoreMapper {

    //添加出库单
    @Insert("insert into out_store values (null,#{clientId},#{productId},#{storeId}," +
            "#{salePrice},#{outNum},#{createBy},now(),0)")
    int insertOutStore(OutStore outStore);

    //显示出库列表
    Page<OutStore> selectOutstoreList(OutStore outStore);

    //根据id修改状态为已入库
    @Update("update out_store set is_out = 1 where outs_id = #{outsId}")
    int setIsOutById(Integer outsId);

    //统计今日出库数量
    @Select("select sum(out_num) from out_store where create_time >= #{param1} and create_time <= #{param2}")
    Integer todayOutStoreNum(LocalDateTime begin, LocalDateTime end);

    //统计每月的出库数量
    @Select("select sum(out_num) from out_store where create_time >= #{param1} and create_time <= #{param2}")
    Integer monthOutstoreNum(String begin, String end);
}
